package main.java.indi.zyj.coderecord;

public class WiggleMaxLength {


    public int wiggleMaxLength(int[] nums) {

        int len = nums.length;
        int pre = 0, cur = 0;
        int res = 0;

        for (int i = 1; i < len; i++) {
            cur = nums[i] - nums[i - 1];
            if ((cur > 0 && pre <= 0) || (cur < 0 && pre >= 0)) {
                res++;
                pre = cur;
            }
        }

        return res;

    }

}
